package com.example.demo.controller;

import com.example.demo.model.ListConfig;
import com.example.demo.model.Student;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/R")
public class PropertiesController {

    //别搞忘及$
//   @Value("${mykey.key1}")
//    private String key1;
//   @Value("${maybe}")
//   private Integer key2;
//   @Value("${zero}")
//   private String key3;
   @Value("${string.value:default}")
   private String key4;
   @Value("${m.value}")
   private Object key5;
   @Autowired
   private Student student;
   @Autowired
   private ListConfig listConfig;

//    @RequestMapping("/key")
//    public String key(){
//        return "key1="+key1+"和key2="+key2;
//    }
    //这个初始化注解，在属性注入之后，在启动类开始之前
    @PostConstruct
    public void init(){
//        System.out.println("key1"+key1);
//        System.out.println("key2"+key2);
//        System.out.println("key3"+key3);
        System.out.println("key4 "+key4);
        System.out.println("key5 "+key5);
        System.out.println(student);
        System.out.println(listConfig);
    }

}
